<template>
	<div class="padding-lr-xs">
	  <a-form-model :model="processData">

      <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="执行监听器"
      >
        <a-button type="primary" size="small" @click="showExecute(1)"
        >编辑</a-button
        >
      </a-form-item>
      <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          v-if="formData.type == 'bpmn:UserTask'"
          label="任务监听器"
      >
        <a-button type="primary" size="small" @click="showExecute(2)"
        >编辑</a-button
        >
      </a-form-item>

	  </a-form-model>
	</div>
</template>

<script>
import userPopup from "@/components/TopVUI/custom/userPopup";
import rolePopup from "@/components/TopVUI/custom/rolePopup";
export default {
  name: "AdvancedSetting",
  components: { userPopup, rolePopup },
  data() {
    return {
			isUserPopup: false,
			isRolePopup: false,
      labelCol: {
        xs: {
          span: 24,
        },
        sm: {
          span: 7,
        },
      },
      wrapperCol: {
        xs: {
          span: 24,
        },
        sm: {
          span: 17,
        },
      },
		}
	},
	props: {
	  processData: {
	    type: Object,
	    required: true,
	  },
	  modeler: {
	    type: Object,
	    required: true,
	  },
	  element: {
	    type: Object,
	    required: true,
	  },
	  authData: {
	    type: Object,
	    required: true,
	  },
	  isProcess: {
	    type: Boolean,
	    default: false,
	  },
	  isEdit: {
	    type: Boolean,
	  },
    formData: {
      type: Object,
      required: true
    },
	},
	watch: {
	  element(val) {
	    /* 流程描述设置 */
	    this.description = "";
	    if (val.businessObject.documentation) {
	      this.description = val.businessObject.documentation[0].text;
	    }
	  },
	},
	methods: {
	  updateProperties(properties) {
	    this.modeler.get("modeling").updateProperties(this.element, properties);
	  },
	  finishSignal(data) {
	    this.signalVisible = false;
	    this.$emit("setFormBtnData", "signalRefList", data);
	  },
	  // 信号定义
	  showSignal(type) {
	    this.refType = type;
	    this.signalVisible = true;
	  },
	  // 流程id
	  updateId(name) {
	    this.updateProperties({ id: name });
	  },
	  // 流程名称
	  updateName(name) {
	    this.updateProperties({ name: name });
	    this.$emit("updateProcesName", name);
	  },
	  // 描述
	  updateDesc(name) {
	    let doc = this.modeler
	      .get("bpmnFactory")
	      .create("bpmn:Documentation", { text: name });
	    this.updateProperties({ documentation: [doc] });
	  },
	  // 设置权限
	  addUser(properties, type) {
	    let params = {};
	    if (type === "appoint") {
	      params = {
	        candidateStarterUsers: properties.userNameId,
	        candidateStarterUsersName: properties.userName,
	        candidateStarterGroups: "",
	        candidateStarterGroupsName: "",
	      };
	    } else if (type === "role") {
	      params = {
	        candidateStarterUsers: "",
	        candidateStarterUsersName: "",
	        candidateStarterGroups: properties.id,
	        candidateStarterGroupsName: properties.userName,
	      };
	    } else {
	      params = {
	        candidateStarterUsers: "",
	        candidateStarterUsersName: "",
	        candidateStarterGroups: "",
	        candidateStarterGroupsName: "",
	      };
	    }
	    this.updateProperties(params);
	    this.$emit("setStarterData", type, properties.id?properties.id:properties.userNameId);
	    // this.updateProperties({ 'flowable:candidateStarterGroups': val })
	  },
	  changeAuthType(val) {
	    this.updateProperties({ authType: val });
			this.$emit("setStarterData", val, "");
	  },
    showExecute(e) {
      this.visible = true
      this.$refs.execute.getData(e)
    },

    showMultiInstance(){
      this.multiInstanceVisible = true
      if(this.$refs.multiInstance) this.$refs.multiInstance.getFormData()
    }
	}
}
</script>

<style>
</style>
